<template>
  <div class="pagination-wrapper">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="listQuery.page"
      :page-size="listQuery.pageSize"
      :page-sizes="[10, 20, 30, 40, 50]"
      layout="slot, sizes, total"
      :total="listQuery.total"
    >
      <span class="page-tip">每页显示</span>
    </el-pagination>

    <div class="pull-right">
      <div class="page-num">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="listQuery.page"
          :page-size="listQuery.pageSize"
          layout="prev, slot, next"
          :total="listQuery.total"
        >
          <span class="txt-center num">{{ listQuery.page }}/{{ listQuery.totalPages }}</span>
        </el-pagination>
      </div>
      <div class="page-jumper">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="listQuery.page"
          :page-size="listQuery.pageSize"
          layout="jumper"
          :total="listQuery.total"
        >
        </el-pagination>
        <span class="ensure-btn to-page" @click="clickEnter()">
          <i class="topage-con el-icon-caret-right"></i>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "pagination",
  props: ['listQuery'],
  methods: {
    clickEnter() {
      this.$emit("changeCurrentPage", this.listQuery)
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val
      this.listQuery.page = 1
      this.$emit("changeCurrentPage", this.listQuery)
    },
    handleCurrentChange(val) {
      this.listQuery.page = val
      this.$emit("changeCurrentPage", this.listQuery)
    }
  }
};
</script>

